<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Bandit-Blog后台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <c:import url="${pageContext.request.contextPath}/WEB-INF/jsp/commons/backheader.jsp"></c:import>
    <div class="layui-body">
        <fieldset class="layui-elem-quote">修改密码</fieldset>
        <form class="layui-form" id="pwdModify" lay-filter="pwdDemo" action="/PwdModify" method="post" style="width: 1680px">
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="oldPwd" id="oldPwd" placeholder="输入旧密码" required lay-verify= "required|oldPwd">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="newPwd" id="newPwd" placeholder="输入新密码" required lay-verify= "required|newPwd">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="confirmPwd" id="confirmPwd" placeholder="确认新密码" required lay-verify= "required|confirmPwd">

                </div>
            </div>
            <div class="layui-form-item" hidden>
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="username" id="username" required value="${blogger.username}">

                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit id="save_btn">点击修改</button>
                </div>
            </div>
        </form>


    </div>
</div>
<script>
    layui.use(['form'],function () {
        var form =layui.form;
        //自定义验证规则
        form.verify({
            oldPwd: function (value) {
                if (value!="${blogger.password}"){
                    return '旧密码不正确';
                }
            },
            newPwd: [/^[\S]{6,18}$/, '密码必须6到18位，且不能出现空格'],
            confirmPwd: function (value) {
                var npwd = form.val('pwdDemo').newPwd;
                if (value != npwd) {
                    return '新密码前后不一致';
                }
            }
        });
    })

</script>
</body>
</html>
